package cn.tedu.store.util;

import cn.tedu.store.service.IRepairService;
import cn.tedu.store.service.PbkoXxkService;
import cn.tedu.store.service.Switchseivice;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.scheduling.TaskScheduler;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.text.ParseException;


/**
 * 定时查询学生晨跑记录
 * @author Administrator
 */
@Component("Task")
@EnableScheduling
@EnableAsync
@Slf4j
public class TimerProcessTaskTest {



        @Bean
        public TaskScheduler taskScheduler() {
            ThreadPoolTaskScheduler scheduling = new ThreadPoolTaskScheduler();
            scheduling.setPoolSize(10);
            scheduling.initialize();
            return scheduling;
        }
//    @Scheduled(cron = "0/2 * * * * ?")
//    public void doTask() throws InterruptedException {
//        log.info(Thread.currentThread().getName()+"===task run");
//        Thread.sleep(5);
//
//    }
//    @Scheduled(cron = "0/2 * * * * ?")
//    public void doTask1() throws InterruptedException {
//        log.info(Thread.currentThread().getName()+"===task end");
//    } @Scheduled(cron = "0 35 8 * * ?")
        @Resource
        StringRedisTemplate stringRedisTemplate;
    @Resource
    IRepairService repairService;
//    /**
//     * 每五秒执行一次
//     */
//    @Scheduled(cron = "0 */10 * * * ?")
//    private void printNowDate() {
//    repairService.send();
//    }


//    @Scheduled(cron = "0 35 15 * * ?")
//    private void    daily(){
//        repairService.daily();
//    }

    @Resource
    Switchseivice switchseivice;
    //早上  0 50 7 ? * 2-6   每天7点半 0 50 7 * * ?
    @Scheduled(cron = "0 50 7 ? * 2-6")
    private void    morningClock(){
        String name = "打卡开关";
            repairService.morningClock();

        log.info("早上打卡开关");
    }
//
//    //下午0 30 17 * * ?
    @Scheduled(cron = "0 30 17 ? * 2-6")
    private void    morning(){
        String name = "打卡开关";

            log.info("下午打卡开关");
            repairService.Clock();


    }


    //每日提醒
//    @Scheduled(cron = "0 0 8 * * ?")
    private void mrtx(){
        repairService.mrtx();
    }



    //拉取oa办公数据
@Scheduled(cron = "0 0/2 * * * ?  ")
    private void workFlow() throws ParseException {

        repairService.sendWorkFlow();

    }
    @Resource
    PbkoXxkService pbkoXxkService;
    //拉取oa办公数据
    @Scheduled(cron = "0 0/2 * * * ?  ")
    private void addMac() throws ParseException {

        pbkoXxkService.add();

    }

    public static void main(String[] args) {
        String s= "642f-c76a-65a0";
        String s1 = s.replaceAll("-", "").replaceAll("(.{2})", ":$1").substring(1);
        String substring = s1.replaceAll("(.{2})", ":$1").substring(1);

        System.out.println(substring);

    }

    private void preService(){
        pbkoXxkService.contrastMac();
    }
}

